home *** CD-ROM | disk | FTP | other *** search
Wrap
Visual Basic class definition | 2001-04-13 | 3.5 KB | 97 lines
VERSION 1.0 CLASS BEGIN MultiUse = -1 'True Persistable = 0 'NotPersistable DataBindingBehavior = 0 'vbNone DataSourceBehavior = 0 'vbNone MTSTransactionMode = 0 'NotAnMTSObject END Attribute VB_Name = "SmartTagRecognizer" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = True Option Explicit Implements ISmartTagRecognizer Dim terms(20) As String Dim numTerms As Integer Private Sub Class_Initialize() ' Declare these terms in all lowercase so that ' case-insensitive searches can be performed. terms(1) = "mocha latte" terms(2) = "latte" terms(3) = "carmelito" terms(4) = "verona" terms(5) = "columbia blend" terms(6) = "antigua" terms(7) = "kona" terms(8) = "sunani" terms(9) = "sumatra" terms(10) = "espresso" terms(11) = "java" numTerms = 11 End Sub Private Property Get ISmartTagRecognizer_ProgId() As String ' Create a unique identifier for this recognizer ' that corresponds to the ProgID of this dll. ISmartTagRecognizer_ProgId = "SimpleTerm.SmartTagRecognizer " End Property Private Property Get ISmartTagRecognizer_Name(ByVal LocaleID As Long) As String ' Add a short phrase that describes this recognizer that will be ' shown in the Tools>Autocorrect Option>Smart Tags ' dialog box in both Word and Excel. ISmartTagRecognizer_Name = "My Simple Term Recognizer" End Property Private Property Get ISmartTagRecognizer_Desc(ByVal LocaleID As Long) As String ' Create a longer description of this recognizer. ISmartTagRecognizer_Desc = "Simple Term Recognizer recognizes Fourth Coffee flavors in documents" End Property Private Property Get ISmartTagRecognizer_SmartTagCount() As Long ' Specify the number of smart tag types this recognizer supports. ' 1 in this case. ISmartTagRecognizer_SmartTagCount = 1 End Property Private Property Get ISmartTagRecognizer_SmartTagName(ByVal SmartTagID As Long) As String ' Provide the name of the smart tag type supported. ' SmartTag names are always in the format of ' namespaceURI#tagname. If (SmartTagID = 1) Then ISmartTagRecognizer_SmartTagName = "schemas-fourth-com/fourthcoffee#flavor" End If End Property Private Property Get ISmartTagRecognizer_SmartTagDownloadURL(ByVal SmartTagID As Long) As String ' For this particular smart tag type, there is no website ' to support a smart tag download URL, so return nothing. ISmartTagRecognizer_SmartTagDownloadURL = "" End Property Public Sub ISmartTagRecognizer_Recognize(ByVal Text As String, ByVal DataType As SmartTagLib.IF_TYPE, ByVal LocaleID As Long, ByVal RecognizerSite As SmartTagLib.ISmartTagRecognizerSite) Dim i As Integer Dim index As Integer, termlen As Integer Dim propbag As SmartTagLib.ISmartTagProperties Text = LCase(Text) For i = 1 To numTerms index = InStr(Text, terms(i)) termlen = Len(terms(i)) While (index > 0) ' Ask the recognizer site for a property bag Set propbag = RecognizerSite.GetNewPropertyBag ' Commit the smart tag to the application RecognizerSite.CommitSmartTag "schemas-fourth-com/fourthcoffee#flavor", index, termlen, propbag ' Look for another smart tag in the string index = InStr(index + termlen, Text, terms(i)) Wend Next i End Sub